<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script>
      // for (var i = 1, sum = 0; i <= 100; i++) {
      //   console.log(i);
      //   sum = sum + i;
      //   if (i === 50) {
      //     // debugger;
      //   }
      // }
      // console.log("总数和为" + sum);

      var obj = {
        name: "孙悟空",
        age: 18,
        gender: "男",
        address: "花果山",
      };
      var obj2 = {
        name: "孙悟空",
      };

      function getNumber(obj) {
        var sum = 0;
        for (var n in obj) {
          sum++;
        }
        return sum;
      }
      // 获取对象一共有多少个属性
      console.log(getNumber(obj)); //4
      console.log(getNumber(obj2)); //1

      // function getNumberCount(n) {
      //   var sum = 0;
      //   for (var i = 1; i <= n; i++) {
      //     sum = sum + i;
      //   }
      //   return sum;
      // }
      // console.log(getNumberCount(100)); //5050
      // console.log(getNumberCount(1)); //1
      // console.log(getNumberCount(2)); //3
      //1+10+100
      function getCount(a, b, c) {
        // var sum = a + b + c;
        // return sum;
        return a + b + c;
      }

      console.log(getCount(1, 10, 100));
      console.log(getCount(1, 10, 100));
    </script>
  </head>
  <body></body>
</html>
